import { service as request, serviceModel as requestModel } from '@/utils/request_web'
// 获取所有模型
export function getModels() {
  return requestModel({
    url: 'models',
    method: 'get'
  })
}
// 新建模型
export function createModel(data) {
  return requestModel({
    url: '/activiti/create',
    method: 'post',
    data: data
  })
}

// 指派模型给部门
export function getAssignModelToDepart(modelId, data) {
  return requestModel({
    url: `/models/updataGroup?modelId=${modelId}`,
    method: 'post',
    data
  })
}
// 通过模型ID获取部门
export function getDepartByModelId(id) {
  return requestModel({
    url: `/models/getGroupsByModel?modelId=${id}`,
    method: 'get'
  })
}
// 删除模型
export function delModel(id) {
  return requestModel({
    url: 'models/delete/' + id,
    method: 'get'
  })
}

// 发布模型
export function deploymentModel(data) {
  return requestModel({
    url: 'process/deploy1',
    method: 'post',
    params: data
  })
}

// 获取所有流程
export function getProcess(depart) {
  return requestModel({
    url: `/process/getProcessByGroup?depart=${depart}`,
    method: 'get'
  })
}

// 查看流程图
export function show(id, type) {
  return requestModel({
    url: '/process/show?did=' + id + '&ext=' + type,
    method: 'get'
  })
}

// 获取节点名称 对应处理签表头
export function getProcessPointNames(taskId) {
  return requestModel({
    url: `/process/${taskId}/nextflowelements`,
    method: 'get'
  })
}
// export function getProcessPointNames(proDefId, currentPoint) {
//   return requestModel({
//     url: `/process/${proDefId}/elements?curNode=${currentPoint}`,
//     method: 'get'
//   })
// }

// 激活或挂起流程
export function setProcessSus(processInstanceId, state) {
  return requestModel({
    url: 'runs/update/' + state + '/' + processInstanceId,
    method: 'get'
  })
}
// 获取通过用户ID和流程ID获取任务信息
export function getTaskInfoByUserIdAndProcessId(params) {
  return requestModel({
    url: 'runtime/tasks/findTask1',
    method: 'get',
    params
  })
}
// 获取通过用户ID和任务ID获取任务信息
export function getTaskInfoByUserIdAndTaskId(params) {
  return requestModel({
    url: 'runtime/tasks/commentbybuskey/',
    method: 'get',
    params
  })
}
// 获取审批记录
export function getCommentmap(proId) {
  return requestModel({
    url: 'runtime/tasks/commentmap',
    method: 'get',
    params: { proId }
  })
}
// 获取审批记录
export function getCommentPro(proInsId, proDefId) {
  return requestModel({
    url: 'runtime/tasks/commentpro',
    method: 'get',
    params: { proInsId, proDefId }
  })
}

// 删除流程定义
export function delProcess(id) {
  return requestModel({
    url: `process/delPrdDef?deploymentId=${id}&type=true`,
    method: 'post'
  })
}

// 通过任务ID删除流程数据
export function delProcessDataByTaskId(id) {
  return requestModel({
    url: `process/tasks/delByBus?bussKey=${id}`,
    method: 'get'
  })
}

// 启动流程
export function startProcess(id, data) {
  return requestModel({
    url: `start/run/${id}`,
    method: 'post',
    data: data
  })
}

// 获取所有任务
export function getAllTask() {
  return requestModel({
    url: 'runs/tasks',
    method: 'get'
  })
}

// 查看个人代签收任务
export function getCandite(userId) {
  return requestModel({
    url: 'runtime/tasks/candite?userId=' + userId,
    method: 'post',
    data: { groups: [] }
  })
}

// 代签收任务
export function claimTask(taskId, data) {
  return requestModel({
    url: 'runtime/tasks/claim/' + taskId,
    method: 'get',
    params: data
  })
}
// 签收并完成任务
export function claimAndCompleteTask(taskId, data) {
  return requestModel({
    url: 'runtime/tasks/claimc/' + taskId,
    method: 'get',
    params: data
  })
}
// 查看任务信息
export function getTaskIdInByBus(data) {
  return requestModel({
    url: `runtime/tasks/findTaskIdInByBus`,
    method: 'get',
    params: data
  })
}

// 查看个人待办
export function TaskIng(userId, type, page) {
  return requestModel({
    url: `runtime/tasks/mying?userId=${userId}&&type=${type}`,
    method: 'get',
    params: { page }
  })
}

// 完成任务
export function completeTasks(taskId, data) {
  return requestModel({
    url: 'runtime/tasks/do/' + taskId,
    method: 'post',
    data: data
  })
}

// 查看当前任务数据
export function bussNow(taskId) {
  return requestModel({
    url: 'runtime/tasks/buss?taskId=' + taskId,
    method: 'get'
  })
}
// 委托
export function postEntrustToOther(taskId, userKey) {
  return requestModel({
    url: 'runtime/turnTask',
    method: 'post',
    params: { taskId, userKey }
  })
}
// 加签
export function postCountersign(taskId, taskName, data) {
  return requestModel({
    url: `/runtime/tasks/addsign?taskId=${taskId}&taskName=${taskName}`,
    method: 'post',
    data
  })
}

// 流程监控
export function getProcessMinitor(proId) {
  return requestModel({
    url: '/history/process/proCount',
    method: 'get',
    params: { proId }
  })
}

// 流程图高亮
export function getProcessMinitorGraph(data) {
  return requestModel({
    url: '/start/show',
    method: 'get',
    params: data
  })
}

// 我的审批已办记录
export function getHasApproves(userId, type, page) {
  return requestModel({
    url: `/process/tasks/myc1?userId=${userId}&&type=${type}`,
    method: 'get',
    params: { page }
  })
}

// 我的发起记录
export function startHi(userId) {
  return requestModel({
    url: 'history/tasks/mys?userId=' + userId,
    method: 'get'
  })
}

// 流程记录查询
export function proHi(proId) {
  return requestModel({
    url: 'history/tasks/pro?proId=' + proId,
    method: 'get'
  })
}
// 审批、收文关联流程信息
export function getTaskProcessInfo(taskId) {
  return requestModel({
    url: `/runtime/tasks/flow/?busKey=${taskId}`,
    method: 'get'
  })
}
// 任务关联流程信息
export function getTaskProcessInfo1(taskId) {
  return request({
    url: `/Work/flow/?busKey=${taskId}`,
    method: 'get'
  })
}
// 导出表格
export function getExportTable(data) {
  return requestModel({
    url: `/excel/exporte1/`,
    method: 'get',
    params: data
  })
}
